﻿using System;

namespace AI_Experiment
{
    class Control
    {
        //starting the simulation and sim runtime methods
        

        //needs method to actually move droids about


        public static void SpawnDroids()
        {
            for (GlobalVars.totalDroids = 0; GlobalVars.totalDroids < GlobalVars.numDroids; GlobalVars.totalDroids++)
            {
                Droid droid = new Droid(GlobalVars.totalDroids);
                GlobalVars.droidlist.Add(droid);
                Console.WriteLine(droid.id + "(" + droid.cur_x + "," + droid.cur_y + ")");
                //Droids_Mainform.spawnDroidsProg.Value = Convert.ToInt32(((double)GlobalVars.totalDroids / (double)GlobalVars.numDroids) * 100);
                System.Threading.Thread.Sleep(50);
            }
            //Droids_Mainform.spawnDroidsProg.Value = 100;
        }

        public static void SpawnFood()
        {
            for (GlobalVars.totalFoods = 0; GlobalVars.totalFoods < GlobalVars.numFoods; GlobalVars.totalFoods++)
            {
                Food food = new Food(GlobalVars.totalFoods);
                GlobalVars.foodlist.Add(food);
                Console.WriteLine(food.Id + "(" + food.cur_x + "," + food.cur_y + ")");
                //spawnFoodProg.Value = Convert.ToInt32(((double)GlobalVars.totalFoods / (double)GlobalVars.numFoods) * 100);
                System.Threading.Thread.Sleep(50);
            }
            //Droids_Mainform.spawnFoodProg.Value = 100;
        }

        public static void runSim()
        {
            //loop so all food is eaten by hungry droids
                Console.WriteLine("Running simulation...");
                for (int i = 0; i <= GlobalVars.totalDroids; i++)
                {
                    ((Droid)GlobalVars.droidlist[i]).setNextMove((Food)GlobalVars.foodlist[i]);
                    Console.WriteLine("totalFoods = " + GlobalVars.totalFoods);
                }
            Console.WriteLine("Simulation complete. All food devoured");
        }
    }
}
